<template>
  <div>
    <home-header :city="city"></home-header>
    <home-swiper :swiperList="swiperList"></home-swiper>
    <home-icons :iconList="iconList"></home-icons>
    <home-recommend :recommendList="recommendList"></home-recommend>
    <home-weekend :weekendList="weekendList"></home-weekend>
  </div>
</template>

<script type="text/javascript">
  import HomeHeader from './components/Header'
  import HomeSwiper from './components/Swiper'
  import HomeIcons from './components/Icons'
  import HomeRecommend from './components/Recommend'
  import HomeWeekend from './components/Weekend'
  import axios from 'axios'

  export default {
    name: 'Home',
    components: {HomeWeekend, HomeRecommend, HomeHeader, HomeSwiper, HomeIcons},
    data () {
      return {
        city: 'test',
        swiperList: [],
        iconList: [],
        recommendList: [],
        weekendList: [],
      }
    },
    mounted () {
      this.getHomeInfo()
    },
    methods: {
      /** 调接口获取首页信息 */
      getHomeInfo () {
        axios.get('/api/index.json')
          .then(this.getHomeInfoSucc)
      },
      /** 获取首页信息成功后的回调方法 */
      getHomeInfoSucc (res) {
        res = res.data
        if (res.ret) {
          this.city = res.data.city
          this.swiperList = res.data.swiperList
          this.iconList = res.data.iconList
          this.recommendList = res.data.recommendList
          this.weekendList = res.data.weekendList
        }
        console.log(res)
      }
    }

  }
</script>
<style lang="stylus">

</style>

